package com.ruoyi.web.controller.production.stroma;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.service.stroma.IStromaAmountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.stroma.StromaPurchase;
import com.ruoyi.production.service.stroma.IStromaPurchaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基质购买信息Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/stromaPurchase")
@Api(value = "基质购买",tags = "基质购买相关API")
public class StromaPurchaseController extends BaseController
{
    @Autowired
    private IStromaPurchaseService stromaPurchaseService;
    @Autowired
    private IStromaAmountService stromaAmountService;

    /**
     * 查询基质购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:stromaPurchase:list')")
    @GetMapping("/list")
    @ApiOperation("获取基质购买表信息")
    @ApiImplicitParam(name = "stromaPurchase",value = "基质购买实体类",paramType = "body", dataType = "StromaPurchase")
    public TableDataInfo list(StromaPurchase stromaPurchase)
    {
        startPage();
        List<StromaPurchase> list = stromaPurchaseService.selectStromaPurchaseList(stromaPurchase);
        return getDataTable(list);
    }

    /**
     * 导出基质购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:stromaPurchase:export')")
    @Log(title = "基质购买信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出基质购买表信息")
    @ApiImplicitParam(name = "stromaPurchase",value = "基质购买实体类",paramType = "body", dataType = "StromPurchase")
    public AjaxResult export(StromaPurchase stromaPurchase)
    {
        List<StromaPurchase> list = stromaPurchaseService.selectStromaPurchaseList(stromaPurchase);
        ExcelUtil<StromaPurchase> util = new ExcelUtil<StromaPurchase>(StromaPurchase.class);
        return util.exportExcel(list, "基质购买信息数据");
    }

    /**
     * 获取基质购买信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:stromaPurchase:query')")
    @GetMapping(value = "/{stromaPurchaseId}")
    @ApiOperation("获取基质购买表单个信息")
    @ApiImplicitParam(name = "stromaPurchaseId",value = "基质购买实体类主键",paramType = "path", dataType = "Long")
    public AjaxResult getInfo(@PathVariable("stromaPurchaseId") Long stromaPurchaseId)
    {
        return AjaxResult.success(stromaPurchaseService.selectStromaPurchaseById(stromaPurchaseId));
    }

    /**
     * 新增基质购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:stromaPurchase:add')")
    @Log(title = "基质购买信息", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    @ApiOperation("新增基质购买表信息")
    @ApiImplicitParam(name = "stromaPurchase",value = "基质购买实体类",paramType = "body", dataType = "StromaPurchase")
    public AjaxResult add(@RequestBody StromaPurchase stromaPurchase)
    {
        return toAjax(stromaPurchaseService.insertPurchaseUpdateAmount(stromaPurchase));
    }

    /**
     * 修改基质购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:stromaPurchase:edit')")
    @Log(title = "基质购买信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    @ApiOperation("修改基质购买表信息")
    @ApiImplicitParam(name = "stromaPurchase",value = "基质购买实体类",paramType = "body", dataType = "StromaPurchase")
    public AjaxResult edit(@RequestBody StromaPurchase stromaPurchase)
    {
        return toAjax(stromaPurchaseService.updateStromaPurchase(stromaPurchase));
    }

    /**
     * 删除基质购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:stromaPurchase:remove')")
    @Log(title = "基质购买信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stromaPurchaseIds}")
    @ApiOperation("删除基质购买表信息")
    @ApiImplicitParam(name = "stromaPurchaseIds",value = "基质购买实体类主键数组",paramType = "path", dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] stromaPurchaseIds)
    {
        return toAjax(stromaPurchaseService.deleteStromaPurchaseByIds(stromaPurchaseIds));
    }
}
